(Al-Baqara) 2 : 240
وَالَّذِينَ يُتَوَفَّوْنَ مِنْكُمْ وَيَذَرُونَ أَزْوَاجًا وَصِيَّةً لِأَزْوَاجِهِمْ مَتَاعًا إِلَى الْحَوْلِ غَيْرَ إِخْرَاجٍ ۚ فَإِنْ خَرَجْنَ فَلَا جُنَاحَ عَلَيْكُمْ فِي مَا فَعَلْنَ فِي أَنْفُسِهِنَّ مِنْ مَعْرُوفٍ ۗ وَاللَّهُ عَزِيزٌ حَكِيمٌ
And those among you who pass away leaving wives should bequest for their wives a year’s sustenance without expelling them, then if they leave there is no blame upon you if they take their decisions according to their wishes in Justice, and Lord Allah is the Exalted, the Wise.
This verse is encouraging the widow to be married by the deceased husband’s brothers. But if the widow wishes to leave the house and marry another person, there is no blame upon both parties. See explanation 2: 129.